Skip to content

Feat/direct fee read only#410

Merged
Mosas2000 merged 10 commits into
mainfrom
feat/direct-fee-read-only
May 19, 2026
Merged

Feat/direct fee read only#410
Mosas2000 merged 10 commits into
mainfrom
feat/direct-fee-read-only

Conversation

@Mosas2000

Copy link
Copy Markdown
Owner

Smart contract (
tipstream.clar
)

Added get-fee-summary(amount uint) — a single read-only call that returns the complete fee picture as a tuple: fee-basis-points, basis-points-divisor, min-fee-ustx, fee-percent, fee-for-amount, amount, and net-amount. No inference needed anywhere.

Frontend config (
contracts.js
)

Added FN_GET_FEE_FOR_AMOUNT and FN_GET_FEE_SUMMARY constants.

Frontend lib (
admin-contract.js
)

Added fetchFeeForAmount(amountMicroSTX) and fetchFeeSummary(amountMicroSTX) — both call the contract directly via the read-only API and return typed results.

Frontend hook (
useContractFee.js
)

New useContractFee hook that fetches the live current-fee-basis-points from the contract on mount and at a configurable poll interval. Falls back to the SDK's compile-time constant when the contract is unreachable, so the fee preview never breaks. Returns feeBasisPoints, feePercent, loading, error, isLive, and refresh.

SendTip.jsx

Replaced the hardcoded FEE_PERCENT import with useContractFee. All fee calculations — balance check, post-condition ceiling, fee preview, and confirm dialog — now use the live on-chain rate passed as feeBasisPoints to the SDK helpers.

AdminDashboard.jsx

Added a "Current Fee Rate" status card to the status bar, reading from feeState.currentFeeBasisPoints so the admin always sees the live rate without a separate lookup.

useAdmin.js

Initialised currentFeeBasisPoints: 0 in the feeState default so the admin dashboard renders cleanly before data loads.

Closes #344

@Mosas2000 Mosas2000 merged commit ce3a22f into main May 19, 2026
4 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a direct read-only contract function for the current fee rate

1 participant